Skip to content

Fix slow vertical rotation in the Sphinx viewer on tall pages - #2124

Merged
adam-urbanczyk merged 1 commit into
CadQuery:masterfrom
shimwell:fix-viewer-event-positions
Nov 6, 2026
Merged

adam-urbanczyk merged 1 commit into
CadQuery:masterfrom
shimwell:fix-viewer-event-positions

Conversation

@shimwell

@shimwell shimwell commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Rotating a model in the cadquery Sphinx directive by dragging up and down is very slow on long pages with some themes (I hit it with pydata_sphinx_theme). Left and right is fine.

The interactor is bound to document.body, and vtk.js scales mouse positions by the size of the element it is bound to. The canvas is window sized but the body can be the full page height, so vertical movement gets shrunk by page height / window height. The CadQuery docs theme keeps the body window sized, which is why it doesn't show up there.

This binds the interactor to a small object that still listens on the body but reports the canvas size.

On a ~26800 px tall page, a 200 px vertical drag rotated 2.7 deg before and 80 deg after, the same as on the CadQuery docs.

this is also visible when trying to rotate images in the older versions of the paramak docs

The interactor was bound to document.body and vtk.js scales mouse
positions by the size of the bound element, so on pages where the body
is taller than the window vertical drags were shrunk. Bind to an object
that listens on the body but reports the canvas size.
shimwell added a commit to fusion-energy/paramak that referenced this pull request Nov 4, 2026
* Fix mouse rotation in the interactive docs viewer

The CadQuery viewer binds the vtk.js interactor to document.body, which
on long pages shrinks vertical drags so up and down rotation was very
slow. cq_viewer.js binds to an object that reports the canvas size (to
be removed once a CadQuery release includes CadQuery/cadquery#2124) and
makes rotation the same angle per pixel in both directions.

* Show the mouse controls as hover text on the interactive docs views
@codecov

codecov Bot commented Nov 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.81%. Comparing base (8178185) to head (50ae3b6).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2124   +/-   ##
=======================================
  Coverage   95.81%   95.81%           
=======================================
  Files          30       30           
  Lines        9605     9605           
  Branches     1443     1443           
=======================================
  Hits         9203     9203           
  Misses        247      247           
  Partials      155      155           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@adam-urbanczyk

Copy link
Copy Markdown
Member

Seems to be working fine, docs related so merging.

@adam-urbanczyk
adam-urbanczyk merged commit 477d87d into CadQuery:master Nov 6, 2026
6 checks passed
shimwell added a commit to fusion-energy/paramak that referenced this pull request Nov 6, 2026
CadQuery/cadquery#2124 is merged, so the docs install CadQuery from the
main branch until it is in a release and cq_viewer.js no longer rebinds
the interactor.
shimwell added a commit to fusion-energy/paramak that referenced this pull request Nov 6, 2026
)

CadQuery/cadquery#2124 is merged, so the docs install CadQuery from the
main branch until it is in a release and cq_viewer.js no longer rebinds
the interactor.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants